<script>
    $(function(){
        $('a').button();

        var timeout = 1000;
        var timer;
        var first = true;

        $(document).ready(function() {
            timer = $.timer(timeout, function() {
                if(first){
                    first = false;
                }else{
                    $("#frmCheckStatus").submit();
                }
            });
        });

        $("#frmCheckStatus").submit(function(){
            $.ajax({
                type: "GET",
                url: "../ajax/checkStatus",
                data: {
                    c_id:$('input#c_id').val(),
                    p_id:$('input#p_id').val()
                },
                dataType: "html",
                success: function(data){
                    if(data=="true"){
                        window.location = '<?php echo URL::base()?>patient/livecamera?c_id='+$('input#c_id').val()+'&p_id='+$('input#p_id').val();
                    }else{

                    }
                }
            });
            return false;
        });
    });
</script>

<table class="ui-widget ui-widget-content ui-corner-all" width="300" border="0">
    <tr class="ui-widget-header">
        <td align="center" valign="top">
            กำลังติดต่อคุณหมอ</td>
    </tr>
</table>

<div style="width: 300px;height: 350px;overflow:auto;padding-left: 5px;background-color:white" align="center"><br>
    กรุณารอสักครู่<br><br>
    <form id="frmCheckStatus" name="frmCheckStatus" action="">
        <input type="hidden" id="c_id" name="c_id" value="<?php echo $c_id?>">
        <input type="hidden" id="p_id" name="p_id" value="<?php echo $p_id?>">       
    </form>
    <?php echo html::image('assets/images/waiting.gif')?>
    <br><br><br>
    <a href=<?php url::base()?>"../patient/cancelContract?p_id=<?php echo $p_id?>">ยกเลิก</a>
</div>


